﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

using ES.Model;

namespace ES.Client.Web.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var data = new List<HYEvent>();
            var keyword = "姚世荣";
            var elastic = new ElasticHub<HYEvent>();
            elastic.Client.ClusterHealth();
            var parameter = elastic.NewParameter();
            parameter.Must.EQ("IsDeleted", false).Like(e => e.Title, keyword);
            parameter.Sorter.Descending(t => t.SubType);
            parameter.Size = 10000;
            parameter.From = 0;
            var response = elastic.Search(parameter);
            if (response.IsValid)
            {
                data = response.Documents.ToList();
            }

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}